<?php

!defined('IN_NOVA') && exit('Access Denied!');

class Article {

	public function start() {
		global $request,$cache,$db,$theme;

		if( $cache->config['arttype'] == '伪静态' ) {
			$temp = $request->get( 'extra' );
			$temp_arr = $db->fetch_one_array( "SELECT id,title,keywords,description,category FROM `" . DB_PREFIX . "article` WHERE id='$temp' OR address='$temp'" );
			if( $temp_arr === FALSE || $cache->category[$temp_arr['category']]['alias'] != $request->get( 'p' ) ) {
				$theme->err_404();
				return;
			}
		} else {
			$id = $request->p;
			$temp_arr = $db->fetch_one_array( "SELECT id,title,keywords,description,category FROM `" . DB_PREFIX . "article` WHERE id=" . $id );
			if( $temp_arr === FALSE ) {
				$theme->err_404();
				return;
			}
		}

		$theme->id = $temp_arr['id'];
		$theme->cid = $temp_arr['category'];
		$theme->title = $temp_arr['title'];
		$theme->keywords = $temp_arr['keywords'];
		$theme->description = $temp_arr['description'];
		$temp = $theme->js_foot;
		array_push( $temp, APP_PATH . 'index.php?m=count&p=' . $temp_arr['id'] );
		$theme->js_foot = $temp;
		unset( $temp, $temp_arr );
		$theme->load('read');
	}
}
?>
